/*
model for mcv format.
*/

#ifndef MYCONTROLLER_H
#define MYCONTROLLER_H

#include <vector>

#include "mvc/myview.h"
#include "mvc/mymodel.h"

class MyView;
class MyModel;

class MyController {
  private:

  protected:
    MyController* parent;
    std::vector<MyController*> children;

    MyView* view;
    MyModel* model;

  public:
    
    // ----------------- constructors ---------------- //
    MyController();
    MyController(MyController*);

    // --------------- getters/setters --------------- //
    MyModel* getModel();
    void setModel(MyModel*);

    MyView* getView();
    void setView(MyView*);

    MyController* getParent();
    void setParent(MyController*);

    // ------------------- other --------------------- //
    void addChild(MyController*);
    void removeChild(MyController*);

    void sendUpward(ALLEGRO_EVENT* ev);

    void hitTest(ALLEGRO_EVENT* ev);

    // this method does NOT transfer children to the new controller
    void swapMeFor(MyController*);

    void killChildren();
    void kill();

    // ------------------ virtual -------------------- //
    virtual void processEvent(ALLEGRO_EVENT*);
    virtual bool insideMe(int x, int y);

};

#endif

